﻿using AutoMapper;
using MediatR;
using S.PurchaseAndSales.Api.Application.Command.PurchaseFormCommand;
using S.PurchaseAndSales.Domain.Model;
using S.PurchaseAndSales.Infrastructure.Interface.PurchaseForm;

namespace S.PurchaseAndSales.Api.Application.CommandHandlers.PurchaseFormHandler
{
    /// <summary>
    /// 采购添加
    /// </summary>
    public class PurchaseFormAddCommandHandler : IRequestHandler<PurchaseFormAddCommand, bool>
    {
        #region 注入
        private readonly IPurchaseFormRepository repository;

        public PurchaseFormAddCommandHandler(IPurchaseFormRepository repository)
        {
            this.repository = repository;
        }

        #endregion
        public async Task<bool> Handle(PurchaseFormAddCommand request, CancellationToken cancellationToken)
        {
            return await repository.AddRangePurchaseForm(request.PurchaseFormList);
        }
    }
}
